/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q2520.java
 * @Author : WangRuoyu
 * @Date 2023/1/10 10:30
 */

package leetcode;

public class Q2520 {
    public int countDigits(int num) {
        int res = 0;
        int tmp = num;

        while (tmp > 9) {
            int mod = tmp % 10;
            if ((num % mod) == 0) {
                res++;
            }
            tmp = tmp / 10;
        }
        if ((num % tmp) == 0) {
            res++;
        }
        return res;
    }

    public static void main(String[] args) {
        Q2520 sl = new Q2520();
        int num = 121;
        System.out.println(sl.countDigits(num));
    }
}
